<?php

namespace app\admin\controller;

use think\App;
use think\Request;
use app\admin\services\UserService;
use app\admin\services\AuthentService;
use app\admin\services\AuthruleService;

class Auth extends Authent
{
    public function __construct(Request $request = null, App $app = null)
    {
        parent::__construct($request, $app);
        $this->UserService = new UserService();
        $this->AuthentService = new AuthentService;
        $this->AuthruleService = new AuthruleService;
        global $authstate;
        if(isset($authstate['status']) && $authstate['status'] !=0 ){
            echo alert_auth("无访问权限!");
            exit();
        }

    }


    /**
     * @return mixed
     * 权限列表
     */
    public function index()
    {
        $data = $this->AuthruleService->listonts();
        $nact = $this->AuthruleService->Navcat();
        $this->assign('rolue',$data);
        $this->assign('nact',$nact);
        return $this->fetch();
    }


    /**
     * @param 权限列表
     */
    public function selecsl(){
        $data = $this->AuthruleService->Listont();
        return json($data);
    }


    /**
     * @param 添加权限
     */
    public function add(){
        $data = $this->AuthruleService->addauth();
        return json($data);
    }


    /**
     * @param 修改权限
     */
    public function edit(){
        $data = $this->AuthruleService->editdata();
        return json($data);
    }


    /**
     * @param 删除权限
     */
    public function del(){
        $data = $this->AuthruleService->deldata();
        return json($data);
    }

}